/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package haw.pr2.A2a.implementations;

import haw.pr2.A2a.interfaces.Acc;
import haw.pr2.A2a.interfaces.Force;
import static haw.pr2.A2a.implementations.UtilityclassValues.*;
import haw.pr2.A2a.interfaces.Mass;
/**
 *
 * @author Fabian Heidorn, Alexander Kaack
 */
class ForceInN extends AbstractScalar<Force> implements Force, Comparable<Force> {
    private final double forceInN;

    ForceInN(double forceInN) {
        this.forceInN=forceInN;
    }

    @Override
    public Force inverse() {
        return new ForceInN(-this.n());
    }

    @Override
    public Force add(Force value) {
        return new ForceInN(this.n()+value.n());
    }

    @Override
    public Force sub(Force value) {
        return new ForceInN(this.n()-value.n());
    }

    @Override
    public Force mul(double value) {
        return new ForceInN(this.n()*value);
    }

    @Override
    public Force div(double value) {
        return new ForceInN(this.n()/value);
    }

    @Override
    public double div(Force value) {
        return this.n()/value.n();
    }

    @Override
    public boolean isZero() {
        return this.equals(ZERO_FORCE);
    }

    @Override
    public boolean isValid() {
        return true;
    }
    
    @Override
    public double n() {
        return this.forceInN;
    }
    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (!(obj instanceof Force)) return false;
        return this.compareTo((Force)obj) == 0;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 53 * hash + (int) (Double.doubleToLongBits(this.forceInN) ^ (Double.doubleToLongBits(this.forceInN) >>> 32));
        return hash;
    }
    
    @Override
    public int compareTo(Force f) {
       return Double.compare(this.n(), f.n());
    }

    @Override
    public double toDouble() {
        return this.n();
    }
    
    // @Override
    public static Force valueOf(double value) {
        return new ForceInN(value);
    }

    @Override
    public Acc divA(Mass m) {
        return new AccInMs(this.div(m.kg()).n());
    }
}
